<?php
	App::uses('AppModel', 'Model');

	class Category extends AppModel {

		function enable($id) { // hiện Category

		    return $this->setEnable($id, true); // delegate
		}

		function disable($id) { // ẩn Category

	    	return $this->setEnable($id, false); // delegate
		}

		function setEnable($id, $enable) {

		    $category = array(
		        'id' => $id,
		        'enable' => $enable,
		    );
		    $this->set($category);
		    return $this->save(null, false);
		}

		public $validate = array(

			'name' => array(
				'rule' => array('minLength', '10'),
				'required' => true,
				'message' => 'Tối thiểu 10 kí tự',
		));
	}